package o;

import android.util.Log;
import com.huawei.hmf.annotation.NamedMethod;
import com.huawei.hmf.orb.exception.InvocationException;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class fga extends ffe implements InvocationHandler {
    private Object ˋ;
    private String ॱ;

    public static <T> T ˏ(ffb o_ffb, T t, Long l) {
        return Proxy.newProxyInstance(t.getClass().getClassLoader(), t.getClass().getInterfaces(), new fga(o_ffb, l, (Object) t));
    }

    public static <T> T ॱ(ffb o_ffb, Class<?>[] clsArr, Long l) {
        InvocationHandler o_fga = new fga(o_ffb, l, null);
        return Proxy.newProxyInstance(o_fga.getClass().getClassLoader(), clsArr, o_fga);
    }

    public static <T> T ˊ(ffb o_ffb, Class<?>[] clsArr, String str, Object... objArr) {
        InvocationHandler o_fga = new fga(o_ffb, str, objArr);
        return Proxy.newProxyInstance(o_fga.getClass().getClassLoader(), clsArr, o_fga);
    }

    private fga(ffb o_ffb, String str, Object... objArr) {
        super(o_ffb);
        this.ॱ = str;
        ˏ(((Long) ˊ(this.ॱ, "__constructor__", new fia<Long>(this) {
            final /* synthetic */ fga ˊ;

            {
                this.ˊ = r1;
            }
        }, objArr)).longValue());
    }

    private fga(ffb o_ffb, Long l, Object obj) {
        super(o_ffb);
        this.ॱ = null;
        ˏ(l.longValue());
        this.ˋ = obj;
    }

    public Object invoke(Object obj, Method method, Object[] objArr) throws Throwable {
        Object invoke;
        if (this.ˋ != null) {
            invoke = method.invoke(this.ˋ, objArr);
        } else {
            invoke = null;
        }
        NamedMethod namedMethod = (NamedMethod) method.getAnnotation(NamedMethod.class);
        if (namedMethod != null) {
            return ˊ(this.ॱ, namedMethod.value(), new fia(method.getGenericReturnType()), objArr);
        }
        if (this.ˋ != null) {
            return invoke;
        }
        StringBuilder stringBuilder = new StringBuilder();
        for (Class name : obj.getClass().getInterfaces()) {
            stringBuilder.append(name.getName());
            stringBuilder.append(",");
        }
        if (method.getReturnType().isPrimitive()) {
            throw new InvocationException(stringBuilder.toString() + " can not found NamedMethod `" + method.getName() + "`");
        }
        Log.e("NamingRemoteProxy", stringBuilder.toString() + " can not found NamedMethod `" + method.getName() + "`");
        return invoke;
    }
}
